package com.utils.basehelper.date;

import com.utils.basehelper.string.date;

import java.util.Calendar;
import java.util.Date;

/**
 * @author: zhaozongyi
 * @date: 2022-07-12 17:11
 */
public class test {
    public static void main(String[] args) {
        int a = getDayOfWeek(new Date());
        System.out.println(a);
        System.out.println(DateUtil1.formatString(DateTimeUtil.getMonthEnd(new Date()),"yyyy-MM-dd"));
        System.out.println(DateUtil1.formatString(DateTimeUtil.setDayOfMonth(new Date(), 0, 1, 3),"yyyy-MM-dd"));
        System.out.println(DateUtil1.formatString(DateTimeUtil.getNextMonthOfDay(3),"yyyy-MM-dd"));
    }

    public static Integer getDayOfWeek(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        boolean isFirstSunday = calendar.getFirstDayOfWeek() == Calendar.SUNDAY;
        int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
        //若一周第一天为星期天，则-1
        if(isFirstSunday){
            weekDay = weekDay - 1;
            if(weekDay == 0){
                weekDay = 7;
            }
        }
        return weekDay;
    }

}
